package com.gzx.plugin.tjzy.modular.phone.filter.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.tjzy.modular.phone.filter.entity.bo.GzxPhoneFilterAddBo;
import com.gzx.plugin.tjzy.modular.phone.filter.entity.bo.GzxPhoneFilterQueryBo;
import com.gzx.plugin.tjzy.modular.phone.filter.entity.vo.GzxPhoneFilterVo;
import com.gzx.plugin.tjzy.modular.phone.filter.service.GzxPhoneFilterService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;

import java.io.IOException;

/**
 * @author zjt
 * @description
 * @date 2025/3/4 12:18
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/tjzy/phone/filter")
public class GzxPhoneFilterController {

    private final GzxPhoneFilterService phoneFilterService;

    @PostMapping("/pageList")
    public CommonResult<Page<GzxPhoneFilterVo>> pageList(@RequestBody GzxPhoneFilterQueryBo filterPhoneQueryBo) throws IllegalAccessException {
        return CommonResult.data(phoneFilterService.pageList(filterPhoneQueryBo));
    }

    @PostMapping("/importExcel")
    @CommonLog("导入过滤手机号")
    public CommonResult<Void> importExcel(String projectCode, @RequestParam("file") MultipartFile multipartFile) throws IOException {
        phoneFilterService.importExcel(projectCode, multipartFile);
        return CommonResult.ok();
    }

    @PostMapping("/add")
    @CommonLog("新增过滤手机号")
    public CommonResult<Void> add(@RequestBody GzxPhoneFilterAddBo filterPhoneAddBo) {
        phoneFilterService.add(filterPhoneAddBo);
        return CommonResult.ok();
    }

    @GetMapping("/delete/{id}")
    @CommonLog("删除过滤手机号")
    public CommonResult<Void> delete(@PathVariable Long id) {
        phoneFilterService.delete(id);
        return CommonResult.ok();
    }
}
